
#include <gio/gio.h>
#include <string.h>
//#include <openssl/ssl.h>
//#ifdef OPENSSL_SSL_H
       #define _XOPEN_SOURCE       /* See feature_test_macros(7) */
       #include <time.h>
#include <locale.h>
typedef gpointer (*callback)(const char *, void *);

const char *get_compile_time();
int main(int argc, char **argv)
{
  g_set_prgname (argv[0]);
  gint rc = 0;
  g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
  g_print ("this program name is :%s\n", g_path_get_basename(g_get_prgname ()));
  setlocale(LC_ALL, "C.UTF-8");

  GDateTime *dt = NULL;
  dt = g_date_time_new_from_iso8601 ("2022-12-21 22:22:11Z", NULL);
  if (dt) {
    g_debug("dt is exist");
    g_date_time_unref (dt);
  }
  goto out;
out:
	return rc;
}
/*
const char *get_compile_time()
{
  const char *date_str = __DATE__;
  const char *time_str = __TIME__;
  char str[1024] = {0};

  g_snprintf (str, sizeof(str), "%s %s", __DATE__, __TIME__);
  g_debug ("str:%s\n", str);
  g_snprintf (str, sizeof(str), "%s %s", date_str, time_str);
  g_debug ("str:%s\n", str);
  GDateTime *dt = NULL;//g_date_time_new_parse (str, "%b %e %Y %H:%M:%S", NULL);
 // GDateTime *dt = g_date_time_new_parse (str, "%b %e %Y %H:%M:%S", NULL);
  struct tm tm;
  memset(&tm, 0, sizeof(struct tm));
  if (strptime(str, "%b %d %Y %H:%M:%S", &tm) == NULL) {
    g_error("Failed to parse the date and time string\n");
  }
  time_t tt;
  tt = mktime (&tm);
  dt = g_date_time_new_from_unix_local (tt);
  char *result = g_date_time_format (dt, "%Y%m%d%H%M%S");
  g_debug ("compile time:%s\n", result);

  // 将从1970年1月1日算起的秒数输出为整型数值
  time_t timestamp = mktime(&tm);
  g_print("The Unix timestamp is: %ld\n", timestamp);
}
{//time
  gchar *time_str = NULL;
  GDateTime *dt = NULL;
  dt = g_date_time_new_now_local();
  time_str = g_date_time_format (dt, "%Y-%m-%d %H:%M:%S");
  g_free (time_str);
  g_date_time_unref (dt);
}
{//"33 22" to 3322
  hex_str = g_strsplit (cmd, " ", 0);
  len = strlen(cmd)/3;
  if (strlen(cmd)%3) {
    len++;
  }
  hex = g_new (gchar, len);
  for (i = 0; i < len; i++) {
    hex[i] = g_ascii_strtoll (hex_str[i], NULL, 16);
  //  g_print ("%02x ", hex[i]);
  }
  g_strfreev (hex_str);
}
*/
